package com.swt.controller;

import com.swt.common.vo.ResponseVo;
import com.swt.domain.OrderDetail;
import com.swt.service.OrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description
 * @Author swt
 * @Date 2022/5/17
 */
@RestController
@RequestMapping("/OrderDetail")
public class OrderDetailController {
    @Autowired
    public OrderDetailService orderDetailService;
    @GetMapping("/{count}/{size}")
    public ResponseVo pageOrderDetail(@PathVariable Integer count, @PathVariable Integer size){
        return ResponseVo.SUCCESS(orderDetailService.pageDetail(count,size));

    }
    @DeleteMapping("/{id}")
    public ResponseVo deleteOrderDetail(@PathVariable String id){
        return orderDetailService.delectDetail(id)>0?ResponseVo.SUCCESS:ResponseVo.FAIL;
    }
    @GetMapping("/{id}")
    public ResponseVo selectOrderDetailById(@PathVariable String id){
        return ResponseVo.SUCCESS(orderDetailService.selectbyidDetail(id));
    }
    @PostMapping
    public ResponseVo insertOrderDetail(@RequestBody OrderDetail s){
        return orderDetailService.inserDetail(s)>0?ResponseVo.SUCCESS:ResponseVo.FAIL;
    }
    @PutMapping
    public ResponseVo updateOrderDetail(@RequestBody OrderDetail s){
        return orderDetailService.updateDetail(s)>0?ResponseVo.SUCCESS:ResponseVo.FAIL;
    }
}

